package com.qf.utils;

/*
 *  @author Administrator
 *  @version V1.0
 *  @Project banwoqiche
 *  @Package com.qf.utils
 *  @Description
 *  @Date2022/3/29 0029 19:32
 */

import com.qf.dto.UserDto;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

public class SecurityUtils {
    public static UserDto getLoginUser() {
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
            return (UserDto) request.getSession().getAttribute("user");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

}
